Repository navigation
Conversation
Each ATOM instance gets one Session, shared by its ranks and opened by its first request. Outputs are split by seq_id into one stream per request that carries what a Generate call sends, so `AtomStream` turns it into token chunks; a dropped request sends Abort, a broken Session fails its requests and the next request opens a new one, a Ready of another protocol version is refused, and seq ids stay below 2^24. Nothing routes requests over it until `--atom-grpc-session`. A non-streaming request's ids are kept from its StreamBatch entries for its Complete, since a Completions item carries none, and each Session runs on a connection, thread and runtime of its own, off the router's runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e atomesh Session link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mod.rs, stream.rs and session_test.rs under engine/atom keep this branch's version: it already holds the Session link's change to them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Two critical request-ID reuse bugs can abort replacement requests through stale stream drops or reordered queued messages, requiring lifecycle and batching fixes with regression tests.
2 open issues
What changed in this PR
Adds atomesh’s client-side Session link, allowing requests to an ATOM instance’s ranks to share one gRPC call. This prepares the transport for opt-in routing in #3679; production routing remains unchanged here.
Changes:
- Adds per-instance Sessions with batched submissions, output routing, cancellation, and reconnection.
- Generalizes
AtomStreamto consume either Generate or Session responses. - Adds tests for shared-rank routing, completion tokens, rejection statuses, cancellation, and Session failures.
| File | Description |
|---|---|
atom/mesh/src/routers/grpc/engine/atom/stream.rs |
Supports Generate and Session response streams. |
atom/mesh/src/routers/grpc/engine/atom/session.rs |
Implements shared Sessions and per-request lifecycle management. |
atom/mesh/src/routers/grpc/engine/atom/session_test.rs |
Tests Session behavior with an in-process server. |
atom/mesh/src/routers/grpc/engine/atom/pair.rs |
Exposes the client helper within the parent module. |
atom/mesh/src/routers/grpc/engine/atom/mod.rs |
Registers the Session module and adds the client RPC method. |
Review effort: Balanced
…dmission into the Session link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ervative cut-off close into the Session link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on a last worker's removal into the Session link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Releasing the last Session handle ended only the client's half of the call: the reader kept reading ATOM's half, and with it the thread, runtime and connection, until ATOM ended the call. The handles now own a signal the reader races against; on it the reader returns, ending the call, whose requests ATOM then aborts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sent request that does not stream keeps its route, and its seq_id, until its Completion after the Abort its drop sends; until then each step's ids were still collected for a Complete no one reads. They are now released once its stream is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and timing fixes into the Session link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Concurrent opening, cancellation, and transport-backpressure races in the cross-runtime Session lifecycle require Python Session integration validation that this environment cannot perform.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
|
Fixes both open issues of this review:
|
…ession link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Cancelling a non-streaming request after tokens accumulate leaves its output buffer allocated until further ATOM activity, requiring immediate buffer cleanup and a regression test that verifies cleanup without another step.
1 open issue
Review effort: Balanced
| if routes | ||
| .open | ||
| .get(&self.seq_id) | ||
| .is_some_and(|route| route.tx.is_closed() && !route.overflowed) | ||
| { | ||
| let _ = self.session.commands.send(Command::Abort(self.seq_id)); | ||
| } |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Cancelling an already-sent non-streaming request retains accumulated output IDs until further peer output arrives, risking prolonged memory retention under backpressure, and the regression test misses this case.
Review effort: Balanced


Part G of the 8 PRs proposed in #3657 (regrouped by function). No blocking issues.
Based on F, the PR below it; it needs E, uses none of F's code, and at runtime calls the Session RPC that C serves.
Why
atomesh had no client for ATOM's Session RPC, so every request to an ATOM worker needed a Generate stream of its own.
What changed
AtomSessions(engine/atom/session.rs) keeps one Session call per ATOM instance, shared by its ranks, on a connection, thread and runtime of its own; opening is bounded at 10 s and holds no lock.SessionStreamcarries what Generate would send, timing included, soAtomStreamreads either; outputs and unsent prompts are bounded.Limits and failure handling
SEQ_IDSnames the Python_SEQ_ID_SHIFTit must equal.AtomSessions::releasing_removed(registry)checks at most once a second; running requests keep their Session to their end.Size: over 1,000 lines, half of them tests: the link is one unit, testable only whole.
Review focus
What a request's stream carries, how long a seq_id stays held, and which messages fail the whole Session.
Testing
Against an in-process Session stub: ranks share one Session, outputs reach only their request, rejections map to HTTP statuses, drops abort, and a broken Session reopens. Also: a missing Ready, an abandoned opening, an unread stream, timing, a 5 MiB message, a released Session, dropped ids, a full queue, an oversized request.
jasen/atom-grpc-g-mesh-session-link@ 6885945: all tests pass, with and withoutatom-engine; fmt clean; clippy adds none.Follow-ups
none
Stack
ATOM serves
atom.grpc.v1.AtomEnginebeside its HTTP server (token ids in, token ids out, ATOM's P/D flow unchanged), and atomesh routes to ATOM gRPC workers over a Generate call per request or one Session per instance. One linear stack, merged bottom to top: A, B, C, D, E, F, G, H; each PR's base is the one before it.Evidence
In
atom/mesh(rustc and clippy 1.100.0), at 6885945:cargo fmt --checkpasses, andcargo clippy --all-targets, with and withoutatom-engine, warns on none of the lines this PR adds.test_load_counter_performance, a throughput check in an untouched file, fails now and then on this shared host (load average 50-140); it passes alone, with and withoutatom-engine.🤖 Generated with Claude Code